using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class PreTag : Tag<PreTag>
    {
        public PreTag() : base("pre"){}
        
        public PreTag(string text) : this()
        {
            Controls.Add(new LiteralControl(text));
        }

        public PreTag(object value) : this()
        {
            Controls.Add(new LiteralControl(SafeString(value)));
        }
        
        
        public PreTag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        
        
        public ATag<PreTag> A()
        {
            var ctrl = new ATag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<PreTag> A(string text)
        {
            var ctrl = new ATag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<PreTag> A(Control control)
        {
            var ctrl = new ATag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<PreTag> A(object value)
        {
            return A(SafeString(value));
        }
        
        public BTag<PreTag> B()
        {
            var ctrl = new BTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<PreTag> B(string text)
        {
            var ctrl = new BTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<PreTag> B(Control control)
        {
            var ctrl = new BTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<PreTag> B(object value)
        {
            return B(SafeString(value));
        }
        
        public BRTag<PreTag> BR()
        {
            var ctrl = new BRTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<PreTag> EM()
        {
            var ctrl = new EMTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<PreTag> EM(string text)
        {
            var ctrl = new EMTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<PreTag> EM(Control control)
        {
            var ctrl = new EMTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<PreTag> EM(object value)
        {
            return EM(SafeString(value));
        }
        
        public ITag<PreTag> I()
        {
            var ctrl = new ITag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<PreTag> I(string text)
        {
            var ctrl = new ITag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<PreTag> I(Control control)
        {
            var ctrl = new ITag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<PreTag> I(object value)
        {
            return I(SafeString(value));
        }
        
        public SpanTag<PreTag> Span()
        {
            var ctrl = new SpanTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<PreTag> Span(string text)
        {
            var ctrl = new SpanTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<PreTag> Span(Control control)
        {
            var ctrl = new SpanTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<PreTag> Span(object value)
        {
            return Span(SafeString(value));
        }
        
        public StrongTag<PreTag> Strong()
        {
            var ctrl = new StrongTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<PreTag> Strong(string text)
        {
            var ctrl = new StrongTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<PreTag> Strong(Control control)
        {
            var ctrl = new StrongTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<PreTag> Strong(object value)
        {
            return Strong(SafeString(value));
        }
        
        public SubTag<PreTag> Sub()
        {
            var ctrl = new SubTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<PreTag> Sub(string text)
        {
            var ctrl = new SubTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<PreTag> Sub(Control control)
        {
            var ctrl = new SubTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<PreTag> Sub(object value)
        {
            return Sub(SafeString(value));
        }
        
        public SupTag<PreTag> Sup()
        {
            var ctrl = new SupTag<PreTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<PreTag> Sup(string text)
        {
            var ctrl = new SupTag<PreTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<PreTag> Sup(Control control)
        {
            var ctrl = new SupTag<PreTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<PreTag> Sup(object value)
        {
            return Sup(SafeString(value));
        }
        
        
        public PreTag Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }

        public PreTag Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
    }

    public class PreTag<ParentType> : ChildTag<PreTag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public PreTag(ParentType parent) : base("pre", parent) { }

        
        
        
        public ATag<PreTag<ParentType>> A()
        {
            var ctrl = new ATag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<PreTag<ParentType>> A(string text)
        {
            var ctrl = new ATag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<PreTag<ParentType>> A(Control control)
        {
            var ctrl = new ATag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<PreTag<ParentType>> A(object value)
        {
            var ctrl = new ATag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BTag<PreTag<ParentType>> B()
        {
            var ctrl = new BTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<PreTag<ParentType>> B(string text)
        {
            var ctrl = new BTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<PreTag<ParentType>> B(Control control)
        {
            var ctrl = new BTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<PreTag<ParentType>> B(object value)
        {
            var ctrl = new BTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BRTag<PreTag<ParentType>> BR()
        {
            var ctrl = new BRTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<PreTag<ParentType>> EM()
        {
            var ctrl = new EMTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<PreTag<ParentType>> EM(string text)
        {
            var ctrl = new EMTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<PreTag<ParentType>> EM(Control control)
        {
            var ctrl = new EMTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<PreTag<ParentType>> EM(object value)
        {
            var ctrl = new EMTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public ITag<PreTag<ParentType>> I()
        {
            var ctrl = new ITag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<PreTag<ParentType>> I(string text)
        {
            var ctrl = new ITag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<PreTag<ParentType>> I(Control control)
        {
            var ctrl = new ITag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<PreTag<ParentType>> I(object value)
        {
            var ctrl = new ITag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SpanTag<PreTag<ParentType>> Span()
        {
            var ctrl = new SpanTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<PreTag<ParentType>> Span(string text)
        {
            var ctrl = new SpanTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<PreTag<ParentType>> Span(Control control)
        {
            var ctrl = new SpanTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<PreTag<ParentType>> Span(object value)
        {
            var ctrl = new SpanTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public StrongTag<PreTag<ParentType>> Strong()
        {
            var ctrl = new StrongTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<PreTag<ParentType>> Strong(string text)
        {
            var ctrl = new StrongTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<PreTag<ParentType>> Strong(Control control)
        {
            var ctrl = new StrongTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<PreTag<ParentType>> Strong(object value)
        {
            var ctrl = new StrongTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SubTag<PreTag<ParentType>> Sub()
        {
            var ctrl = new SubTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<PreTag<ParentType>> Sub(string text)
        {
            var ctrl = new SubTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<PreTag<ParentType>> Sub(Control control)
        {
            var ctrl = new SubTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<PreTag<ParentType>> Sub(object value)
        {
            var ctrl = new SubTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SupTag<PreTag<ParentType>> Sup()
        {
            var ctrl = new SupTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public PreTag<ParentType> Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<PreTag<ParentType>> Sup(string text)
        {
            var ctrl = new SupTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<PreTag<ParentType>> Sup(Control control)
        {
            var ctrl = new SupTag<PreTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<PreTag<ParentType>> Sup(object value)
        {
            var ctrl = new SupTag<PreTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        
        public PreTag<ParentType> Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }
        
        public PreTag<ParentType> Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
        
    }
}